var Login={};
Login.contextpath="";
Login.initPage= function(contextpath){
	Login.contextpath =contextpath;
	// 登录按钮
	$(document).on("click", "#login-button", function() {
		//window.location.href ="/cms-mg/main/main.jsp";
		Login.ajaxLogin();
	});
	
	
	Login.ajaxLogin =function(){
		var username =$("#username").val();
		var password =$("#password").val();
		console.log(username);
		console.log(password);
	    $.ajax({
	        type:"POST",
	        url:"/project/user/login.action",
	        dataType:"json",
	        data:{
	        	"username":username,"password":password
	        },
	        success:function(data){
//	            $("#data").html(data.name + '的任务是' + data.task);
	        	console.log(data);
	        	if(data.code=="0000"){
	        		window.location.href ="/project/main/main.jsp";
	        	}else{
	        		$("#errorMessage").html(data.message);
	        	}
	        },
	        error:function(data){
	            
	        }
	    });
	}
	
}